﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Windows.Forms;
using System.Diagnostics;

namespace Future.CRMClient
{
    static class Program
    {
        /// <summary>
        /// 应用程序的主入口点。
        /// </summary>
        [STAThread]
        static void Main()
        {
            ToCHS();
            Settings.SystemConfig.ReadSettings();
            Process instance = Common.SingletonProgram.GetRunningInstance();
            if ((instance != null) && (!Settings.SystemConfig.CurrentConfig.AllowRunMultiInstance))
            {
                Common.Msg.ShowError("程序已经运行,系统配置不允许运行多个程序!");
                Common.SingletonProgram.HandleRunningInstance(instance);
                return;
            }

            //注册皮肤
            DevExpress.UserSkins.BonusSkins.Register();
            DevExpress.UserSkins.OfficeSkins.Register();
            DevExpress.Skins.SkinManager.EnableFormSkins();

            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            if (AppEntry.Login())
            {
                AppEntry.MainForm.Show();
                Application.Run();
            }
            else
                Application.Exit();
        }

        private static void ToCHS()
        {
            DevExpress.XtraBars.Localization.BarLocalizer.Active = new DevExpress.LocalizationCHS.DevExpressXtraBarsLocalizationCHS();
            DevExpress.XtraEditors.Controls.Localizer.Active = new DevExpress.LocalizationCHS.DevExpressXtraEditorsLocalizationCHS();
            DevExpress.XtraGrid.Localization.GridLocalizer.Active = new DevExpress.LocalizationCHS.DevExpressXtraGridLocalizationCHS();
            DevExpress.XtraNavBar.NavBarLocalizer.Active = new DevExpress.LocalizationCHS.DevExpressXtraNavBarLocalizationCHS();
        }
    }
}
